package leesoft.hub.actions;

import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sisuntech.common.ValueBase;
import com.sisuntech.db.DbUtil;

import leesoft.data.databeans.RegionItem;

public class RegionAction implements IAction {
	HttpServletResponse response;
	HttpServletRequest request;
	public Map process(SessionContext ctx) {
		HashMap<String,List> resultMap=new HashMap<String,List>();
		String sql="select id,name,level from tap_region where parentId='"+request.getParameter("currentId")+"' order by showorder";
		ArrayList resultList = DbUtil.getValueBase(sql);
		ArrayList<RegionItem> items=new ArrayList<RegionItem>();
		for(int i = 0; i < resultList.size(); i++) 
		{
			 ValueBase vb = new ValueBase();
			 vb = (ValueBase)resultList.get(i);
			 RegionItem item;
			 item=new RegionItem();
			 item.setId(vb.getStringValue("id"));
			 item.setName(vb.getStringValue("name"));
			 item.setTypeId(vb.getStringValue("level"));
			 items.add(item);
			 
		}
		
		
		
		resultMap.put("items", items);
		return resultMap;
	}
	public void setRequest(HttpServletRequest request){
		this.request=request;
	}
	public void setResponse(HttpServletResponse response){
		this.response=response;
	}
}